package com.frinder.robot.strategy.action;

import com.frinder.base.strategy.Strategy;
import com.frinder.robot.strategy.action.biz.ConvertForkPalletTaskToActionStrategy;
import com.frinder.robot.strategy.action.biz.ConvertPointToPointTaskToActionStrategy;
import com.frinder.robot.strategy.action.biz.ConvertPutDownPalletTaskToActionStrategy;
import com.frinder.robot.strategy.action.biz.ConvertScanCodeTaskToActionStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @ClassName ConvertTaskToActionHandler
 * @Description 转化机器人任务为动作策略处理器
 * @Author frinder
 * @Date 2019/10/18 14:12
 * @Verion 1.0
 */
@Component
public class ConvertTaskToActionHandler {

    @Autowired
    private ConvertPointToPointTaskToActionStrategy convertPointToPointTaskToActionStrategy;

    @Autowired
    private ConvertForkPalletTaskToActionStrategy convertForkPalletTaskToActionStrategy;

    @Autowired
    private ConvertPutDownPalletTaskToActionStrategy convertPutDownPalletTaskToActionStrategy;

    @Autowired
    private ConvertScanCodeTaskToActionStrategy convertScanCodeTaskToActionStrategy;

    private ConvertTaskToActionBaseStrategy convertTaskToActionBaseStrategy;

    @PostConstruct
    public void post() {
        convertTaskToActionBaseStrategy = new ConvertTaskToActionBaseStrategy();
        convertTaskToActionBaseStrategy
                .register(convertPointToPointTaskToActionStrategy)
                .register(convertForkPalletTaskToActionStrategy)
                .register(convertPutDownPalletTaskToActionStrategy)
                .register(convertScanCodeTaskToActionStrategy);
    }

    /**
     * 处理方法
     *
     * @param payload
     */
    @Strategy
    public void handle(ConvertTaskToActionPayload payload) {
        convertTaskToActionBaseStrategy.handle(payload);
    }
}
